package com.smart.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smart.pojo.ConceptualProduct;
import com.smart.pojo.ResultBean;
import com.smart.req.ConceptualReq;
import com.smart.resp.ConceptualResp;
import com.smart.service.IConceptualProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lyj
 * @since 2023-05-11
 */
@RestController
@RequestMapping("/conceptual")
public class ConceptualProductController {

    @Autowired
    private IConceptualProductService conceptualProductService;

    /**
     * 根据条件分页查询概念产品研发方案
     *
     * @param conceptualReq
     * @return
     */
    @GetMapping("queryByCondition")
    public ResultBean queryByCondition(ConceptualReq conceptualReq) {
        System.out.println("查询概念产品方案的条件：" + conceptualReq);
        Page<ConceptualResp> page = new Page<>(conceptualReq.getPageNum(), conceptualReq.getPageSize());
        conceptualProductService.queryByCondition(conceptualReq, page);
        return ResultBean.success(page);
    }

    /**
     * 根据id获取概念产品信息
     *
     * @param id
     * @return
     */
    @GetMapping("queryById/{id}")
    public ResultBean queryById(@PathVariable("id") Long id) {
        System.out.println("要查询的概念产品id：" + id);
        return ResultBean.success(conceptualProductService.getById(id));
    }

    @GetMapping("queryDeveloped")
    public ResultBean queryDeveloped() {
        System.out.println("获取全部成功研发并未上架的概念产品信息");
        return ResultBean.success(conceptualProductService.lambdaQuery().eq(ConceptualProduct::getStatus, 4).list());
    }
}
